package com.m520it.jdmall03.controller;

import java.util.HashMap;

import com.m520it.jdmall03.bean.RResult;
import com.m520it.jdmall03.cons.IdiyMessage;
import com.m520it.jdmall03.cons.NetworkConst;
import com.m520it.jdmall03.util.NetworkUtil;

public class LoginController extends BaseController {

	private Object mListener;

	@Override
	protected void handleMessage(int action, Object... values) {
		switch (action) {
		case IdiyMessage.LOGIN_ACTION:
			RResult rResult = login((String) values[0], (String) values[1]);
			//mListener.onModeChanged(IdiyMessage.LOGIN_ACTION_RESULT,rResult);
			break;
		}

	}

	private RResult login(String name, String pwd) {
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("username", name);
		params.put("pwd", pwd);
		String jsonStr = NetworkUtil.doPost(NetworkConst.LOGIN_URL, params);

//		return JSON.parseObject(jsonStr, RResult.class);
		RResult rResult = new RResult();
		rResult.setResult(jsonStr);
		return rResult;

	}

}
